package com.hy.erp.inventory.service;

import java.util.List ;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;





import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.PositionDao;
import com.hy.erp.inventory.dao.PositionTypeDao;
import com.hy.erp.inventory.dao.interfaces.IPositionTypeDao;
import com.hy.erp.inventory.dao.interfaces.IPostcodeDao;
import com.hy.erp.inventory.dao.interfaces.IUserDao;
import com.hy.erp.inventory.pojo.PositionType;
import com.hy.erp.inventory.pojo.constant.PojoConstants;
import com.hy.erp.inventory.pojo.interfaces.IPositionType;
import com.hy.erp.inventory.pojo.interfaces.IUser;
import com.hy.erp.inventory.service.interfaces.IPositionTypeService;
import com.hy.mydesktop.shared.persistence.domain.gxt.MyBaseModel;

/**
 * 
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-10-13；时间：上午11:46:10</li>
 * <li>类型名称：PositonTypeService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
//@Name("positonTypeService")
//@Component("positonTypeService")
@Component("positionTypeService")
//public class PositonTypeService	extends	AbstractBusinessService < IPositonType >	implements	IPositonTypeService
public class PositionTypeService	extends	AbstractBusinessService<PositionTypeDao> 	implements	IPositionTypeService
{

	/**
	 * <ul>
	 * <li>开发作者：汤莉</li>
	 * <li>设计日期：2010-10-13；时间：上午11:46:06</li>
	 * <li>字段类型：long；字段名称：serialVersionUID</li>
	 * <li>设计目的：</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 */
	private static final long	serialVersionUID	=
														- 4798117939260891986L ;
	
	private PositionTypeDao positionTypeDao=null;

	@Resource(name="positionTypeDao")
	public void setPositionTypeDao(PositionTypeDao positionTypeDao) {
		this.positionTypeDao = positionTypeDao;
	}

	/**
	 * 
	 * 构造函数
	 */
	public PositionTypeService()
	{
		super ( );
	}
	/*@ Override
	public boolean submitPersistentEntities (List list )
	{		//MyBaseModel[] baseModels = new MyBaseModel[25];
		return super.submitPersistentEntities(list);
		//return true;
		//return positionTypeDao.submitPersistentEntities(list);
		//return true;
		
	}*/
	@Override
	public boolean submitPersistentEntities2(List<MyBaseModel> list) {
		// TODO Auto-generated method stub
		return false;
	}
	@ Override
	public boolean submitPersistentEntities (MyBaseModel[] positonType )
	{		//MyBaseModel[] baseModels = new MyBaseModel[25];

		return positionTypeDao.submitPersistentEntities(positonType);
		//return true;
		
	}
	
	
	@ Override
	public boolean addPositonType (
									PositionType positonType )
	{
		if(positonType==null)
		{
			return true;
		}
		else
		{
//			IPositonTypeDao dao=( IPositonTypeDao ) this.getDao ( IPositonType.class );
			IPositionTypeDao dao=positionTypeDao;
			//IPositonType iPositonType= positonType;
			return dao.persist ( positonType ) ;
		}
	}

	@ Override
	public Integer removePositonType (
										String [ ] Ids )
	{
		if ( ( null == Ids )
			     || ( Ids.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{
//				IPositonTypeDao dao=( IPositonTypeDao ) this.getDao ( IPositonType.class );
				IPositionTypeDao dao=positionTypeDao;
				return dao.remove ( Ids );
			}
	}

	@ SuppressWarnings ( "unused" )
	@ Override
	public boolean modifyPositionType (
										PositionType positonType )
	{
		if ( ( null == positonType ) || ( null == positonType.getIdentifier ( ) ))
		{
			return true;
		}
		else
		{
//			IPositonTypeDao dao=( IPositonTypeDao ) this.getDao ( IPositonType.class );
			IPositionTypeDao dao=positionTypeDao;
			//IPositonType iPositonType= positonType;
			
			if ( null == positonType )
			{
				throw new ArchitectureFoundationException (
				                                            "修改用户实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
			}
			return (dao.merge ( positonType )!=null) ;
		}
	}

	@ Override
	public String [ ] addPositonType (
										Object [ ] objects )
	{
//		IPositonTypeDao dao=( IPositonTypeDao ) this.getDao ( IPositonType.class );
		IPositionTypeDao dao= positionTypeDao;
		PositionType[] types=new PositionType[objects.length];
		for ( int i =
						0 ; i < objects.length ; i ++ )
		{
		  PositionType type=( PositionType ) objects[i];
		  types[i]=type;
		}
		return dao.persist ( types ) ;
	}

	@ Override
	public List < IPositionType > getAllPositonType ( )
	{
//		IPositonTypeDao dao=( IPositonTypeDao ) this.getDao ( IPositonType.class );
		IPositionTypeDao dao=positionTypeDao;
		return dao.find ( ) ;
	}

	@ Override
	public String [ ] modifyPositionType (
											Object [ ] objects )
	{
		if (  null == objects ) 
		{
			return null;
		}
		else
		{
//			IPositonTypeDao dao=( IPositonTypeDao ) this.getDao ( IPositonType.class );
			IPositionTypeDao dao=positionTypeDao;
			PositionType[] types=new PositionType[objects.length];
            for(int i=0;i<objects.length;i++)
            {
            	PositionType type=( PositionType ) objects[i];
            	types[i]=type;
            }
			
			return dao.merge ( types );
            //throw new RuntimeException("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
		}
	}

	@Override
	public PositionType findPositonTypeById(String id) {
		
		return positionTypeDao.findByIdentifier(id);
	}

	

}
